home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************/
- /* */
- /* Copyright (1995) FASTEC GmbH */
- /* */
- /***************************************************************************/
- /*
- Dateiname : ldvslta.h
- Kategorie : C Header Datei
- Zweck : LONTalk Treiber fuer UNIX-Platformen
- Hinweis :
- Autor(en) : Miran Miksic
- Status : beta getestet
- */
- /*-------------------------------------------------------------------------*/
- /*
- Bearbeitungsstand:
- 1996/05/27 15:57:42 v1.1
-
- RCSStand:
- ldvpclta.c,v 1.1 1996/05/27 15:57:42 miksic Exp
- */
- /*-------------------------------------------------------------------------*/
-
- #include "ldv.h"
- #include <errno.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include <sys/time.h>
-
- LDVCode
- ldv_open( const char *device_name, LNI *pHandle )
- {
- LNI handle;
- handle = open( device_name, O_RDWR );
- if( handle < 0 )
- {
- switch( errno )
- {
- case EBUSY:
- case EACCES:
- return LDV_ALREADY_OPEN;
- case ENOENT:
- case ENAMETOOLONG:
- case ENOTDIR:
- return LDV_NOT_FOUND;
- case ENODEV:
- return LDV_NO_RESOURCES;
- default:
- return LDV_DEVICE_ERR;
- }
- }
- *pHandle = handle;
- return LDV_OK;
- }
-
- LDVCode ldv_close( LNI handle )
- {
- if( 0 > close( handle ) )
- return LDV_INVALID_DEVICE_ID;
- return LDV_OK;
- }
-
- LDVCode ldv_read( LNI handle, void *pMsg, unsigned length )
- {
- if( 0 > read( handle, pMsg, length ) )
- {
- switch( errno )
- {
- case EISDIR:
- case EBADF:
- case EINVAL:
- return LDV_INVALID_DEVICE_ID;
- case EINTR:
- case EAGAIN:
- return LDV_NO_MSG_AVAIL;
- case EFAULT:
- return LDV_INVALID_BUF_LEN;
- case EBUSY:
- return LDV_DEVICE_BUSY;
- default:
- return LDV_DEVICE_ERR;
- }
- }
- return LDV_OK;
- }
-
- LDVCode ldv_write( LNI handle, void *pMsg, unsigned length )
- {
- if( 0 > write( handle, pMsg, length ) )
- {
- switch( errno )
- {
- case EISDIR:
- case EBADF:
- case EINVAL:
- return LDV_INVALID_DEVICE_ID;
- case EINTR:
- case EAGAIN:
- return LDV_NO_MSG_AVAIL;
- case EFAULT:
- return LDV_INVALID_BUF_LEN;
- case EBUSY:
- return LDV_DEVICE_BUSY;
- default:
- return LDV_DEVICE_ERR;
- }
- }
- return LDV_OK;
- }
-